<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.commerceE.domain.User,com.commerceE.domain.Product_instance,java.util.*"%>
<% String basePath = request.getContextPath();%>
<% String baseCSSPath = request.getContextPath()+"/resources/css";%>
<% String baseJSPath = request.getContextPath()+"/resources/js";%>
<% String baseImagePath = request.getContextPath()+"/resources/image";%>

<%
User currentUser = (User)session.getAttribute("currentUser");
%>
<div class="heading">
	<b> 我的购物车 </b> <a> <span class="sc-button"></span> <span
		id="cart-total"><%=currentUser.getTotalQuantity()%> 件商品 - <strong>¥<%=currentUser.getTotalPrice() %></strong>
	</span> </a>
</div>
<div class="content">

<%
List<Product_instance> productInstanceListOfSession = null;
if(currentUser!=null){
	productInstanceListOfSession = currentUser.getProductInstanceListOfSession();
}


if(productInstanceListOfSession==null || productInstanceListOfSession.size()==0){
%>
	 <div class="empty">您的购物车为空!</div>
	 
<%
}else{
%>
	<span class="latest-added">您最新选入的商品：</span>
	<div class="mini-cart-info">
	<table class="cart">
<%
	for(Product_instance productInstance : productInstanceListOfSession){
		double price = productInstance.getQuantity() * productInstance.getProduct().getDiscountPrice();
%>
             <tr>
				<td class="image"><a
					href="<%=basePath %>/product/productDetail.html?productId=<%=productInstance.getProduct().getProductId() %>">
					<img
						src="<%=basePath %>/image_upload/<%=productInstance.getProduct().getBestBuyImage().getPath()%>"/>
				    </a></td>
				<td class="name"><a
					href=""><%=productInstance.getProduct().getProductName() %><br/>
					颜色 : <%=productInstance.getColor_product_option_value().getDisplayValue() %><br/>
                                               尺码: <%=productInstance.getSize_product_option_value().getDisplayValue() %>
					</a>
					<div></div> <span class="quantity">&nbsp;<%=productInstance.getQuantity() %></span>件商品 <span
					class="total">¥<%=price %></span><br>
					
					</td>
				<td class="remove"><span> 
				</span>
				</td>
			</tr>


<%		
	}

%>
	
</table>
	</div>
	<div>
		<table class="total">
			<tr>
				<td align="right" class="total-right"><b>Total:</b>
				</td>
				<td align="left" class="total-left"><span class="t-price">¥<%=currentUser.getTotalPrice() %></span>
				</td>
			</tr>
		</table>
	</div>
	<div class="checkout">
		<a class="button"
			href="<%=basePath %>/shoppingCart.html"><span>我的购物车 </span>
		</a> <a class="button"
			href="<%=basePath %>/shoppingCart/checkout_login.html"><span>付款</span>
		</a>
	</div>
	
	<%} %>
</div>
